Biosensor algorithm